﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using GSM.BusinessLayer;


namespace CRM_SMS_MARKETING.PL.Message
{
    public partial class frmMessageManagement : DevExpress.XtraEditors.XtraForm
    {
        public frmMessageManagement()
        {
            InitializeComponent();
        }
        Form checkexist(string fName)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f.Name == fName)
                    return f;
            }
            return null;
        }
        private void GetGridControlVisible(string Name)
        {
            if (Name == "gridControlConsultInbox")
            {
                gridControlConsultInbox.Dock = DockStyle.Fill;
                gridControlConsultInbox.Visible = true;

                
                gridControlMarketDraft.Visible = false;
                gridControlMarketOutbox.Visible = false;
                gridControlMarketSent.Visible = false;
            }
            if (Name == "gridControlConsultTrash")
            {
                gridControlConsultTrash.Dock = DockStyle.Fill;
                gridControlConsultTrash.Visible = true;

                gridControlConsultInbox.Visible = false;
                gridControlMarketDraft.Visible = false;
                gridControlMarketOutbox.Visible = false;
                gridControlMarketSent.Visible = false;
            }
            if (Name == "gridControlMarketDraft")
            {
                gridControlMarketDraft.Dock = DockStyle.Fill;
                gridControlMarketDraft.Visible = true;

                gridControlConsultInbox.Visible = false;
                gridControlConsultTrash.Visible = false;
                gridControlMarketOutbox.Visible = false;
                gridControlMarketSent.Visible = false;
            }
            if (Name == "gridControlMarketOutbox")
            {
                gridControlMarketOutbox.Dock = DockStyle.Fill;
                gridControlMarketOutbox.Visible = true;

                gridControlConsultInbox.Visible = false;
                gridControlConsultTrash.Visible = false;
                gridControlMarketDraft.Visible = false;
                gridControlMarketSent.Visible = false;
            }
            if (Name == "gridControlMarketSent")
            {
                gridControlMarketSent.Dock = DockStyle.Fill;
                gridControlMarketSent.Visible = true;

                gridControlConsultInbox.Visible = false;
                gridControlConsultTrash.Visible = false;
                gridControlMarketDraft.Visible = false;
                gridControlMarketOutbox.Visible = false;
            }
        }
        private void btnInbox_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            gridControlConsultInbox.DataSource = message_ConsultFactory.GetAllBy(Message_Consult.Message_ConsultFields.Type, 1);
            GetGridControlVisible("gridControlConsultInbox");
        }

        private void btnTrash_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

            GetGridControlVisible("gridControlConsultTrash");
        }

        private void btnMarketSent_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            gridControlMarketSent.DataSource = customer_MessageFactory.GetAllBy(Customer_Message.Customer_MessageFields.Type, 3);
            GetGridControlVisible("gridControlMarketSent");
        }

        private void btnMarketOutbox_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            gridControlMarketOutbox.DataSource = customer_MessageFactory.GetAllBy(Customer_Message.Customer_MessageFields.Type, 2);
            GetGridControlVisible("gridControlMarketOutbox");

        }

        private void btnDraft_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            GetGridControlVisible("gridControlMarketDraft");

        }

        Customer_MessageFactory customer_MessageFactory = new Customer_MessageFactory();
        Message_ConsultFactory message_ConsultFactory = new Message_ConsultFactory();
    }
}